package spring.mvc.dao.impl;

import java.util.List;

import spring.mvc.dao.CommentDao;
import spring.mvc.domain.Comment;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class CommentDaoimpl extends SqlSessionDaoSupport implements CommentDao {

	@Override
	public Integer co_write(Comment comment) throws Exception
	{	
		Integer co_seq = getSqlSession().selectOne("comment.co_seq");
		comment.setCo_seq(co_seq);
		getSqlSession().insert("comment.co_write", comment);
		return comment.getSeq();
	}
	
	@Override
	public List <Comment> list(String seq) throws Exception
	{
		List<Comment> list = getSqlSession().selectList("comment.co_list", seq);
		return list;
	}
	
	@Override
	public void co_delete(Comment comment) throws Exception
	{
		getSqlSession().delete("comment.co_delete", comment);
	}
	
	@Override
	public void co_update_com(Comment comment) throws Exception
	{
		getSqlSession().update("comment.co_update_com", comment);
	}
	
}
